
#include "SketchModelWrapper.h"

SketchModelWrapper::SketchModelWrapper(QObject *parent):QObject(parent) {
	model = new SketchModel();

}

void SketchModelWrapper::solve(){
	model->solve();
	emit modelSolved();
}
void SketchModelWrapper::relax(){
	model->relax();
	emit viewChanged();
}
// segments slots
void SketchModelWrapper::addLine(Coordinate c1,Coordinate c2){
	model->addLine(c1,c2);
	emit tablePrimitiveChanged();
	emit viewChanged();
}
void SketchModelWrapper::addCircle(Coordinate c1,Coordinate c2){
	model->addCircle(c1,c2);
	emit tablePrimitiveChanged();
	emit viewChanged();
}
void SketchModelWrapper::addSegment(std::list<Coordinate> cSet){
	model->addSegment(cSet);
	emit tablePrimitiveChanged();
	emit viewChanged();
}
void SketchModelWrapper::pointAdjust(int i, Coordinate c1){
	model->pointAdjust(i,c1);
}
// constraint slots
void SketchModelWrapper::addConnectPoints(int k,int l){
	model->addConnectPoints(k,l);
	emit tableConstraintChanged();
}
void SketchModelWrapper::addFixPoint(int k){
	model->addFixPoint(k);
	emit tableConstraintChanged();
}
void SketchModelWrapper::addPerpendicular(int k,int l, int m,int n){
	model->addPerpendicular(k,l,m,n);
	emit tableConstraintChanged();
}
void SketchModelWrapper::addHorizontal(int k,int l){
	model->addHorizontal(k,l);
	emit tableConstraintChanged();
}
void SketchModelWrapper::addVertical(int k,int l){
	model->addVertical(k,l);
	emit tableConstraintChanged();
}
void SketchModelWrapper::addParallel(int k,int l, int m,int n){
	model->addParallel(k,l,m,n);
	emit tableConstraintChanged();
}
void SketchModelWrapper::addSameLength(int k,int l, int m,int n){
	model->addSameLength(k,l,m,n);
	emit tableConstraintChanged();
}
void SketchModelWrapper::addDistance(int k,int l,skreal paramValue){
	model->addDistance(k,l,paramValue);
	emit tableConstraintChanged();
	emit tableParameterChanged();
}
void SketchModelWrapper::addAngle(int k,int l,int m,int n,skreal paramValue){
	model->addAngle(k,l,m,n,paramValue);
	emit tableConstraintChanged();
	emit tableParameterChanged();
}
void SketchModelWrapper::addTangency(int k,int l,int m,int n){
	model->addTangency(k,l,m,n);
	emit tableConstraintChanged();
}

// TABLE SLOT
void SketchModelWrapper::removeConstraint(int id){
	model->removeConstraint(id);
	emit tableConstraintChanged();
	emit tableParameterChanged();
}
void SketchModelWrapper::removePrimitive(int id){
	model->removePrimitive(id);
	emit tablePrimitiveChanged();
	emit tableConstraintChanged();
	emit viewChanged();

}
void SketchModelWrapper::setParameter(int id,skreal value){
	model->setParameter(id,value);

}

// TABLE DATA
std::map<int,std::string> SketchModelWrapper::getPrimitiveData(){
	return model->getPrimitiveData();
}
std::list<ConstraintData> SketchModelWrapper::getConstraintData(){
	return model->getConstraintData();
}
std::map<int,skreal> SketchModelWrapper::getParameterData(){
	return model->getParameterData();
}

// GRAPHICS VIEW + above getPrimitiveData()
std::map<int,Coordinate> SketchModelWrapper::getPrimitivePoints(int i){
	return model->getPrimitivePoints(i);
}
std::list<std::string> SketchModelWrapper::getMessages(){
	//return model->getMessages();
	return std::list<std::string>();
}
SketchModelWrapper::~SketchModelWrapper() {
	delete model;

}
